-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add a memoized
function and use it throughout rustc
#17983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I'm not super sold on the current syntax and would much prefer for this to be an attribute but that is not possible at the moment. |
fn $name:ident( | ||
$($param_name:ident: $param_ty:ty),* | ||
) -> $output_ty:ty $block:block, | ||
$cache_map:expr, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe these could be moved to be first, so that they're close to the function declaration (as it stands, one has to navigate around a possibly-long function body to find them, made harder by formatting it without indentation).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@huonw Good idea, thanks!
memoized
function and use it throughout rustc
pub fn memoized<T: Clone, U: Clone, M: MutableMap<T, U>>( | ||
cache: &RefCell<M>, | ||
f: &|&: T| -> U, | ||
arg: T |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better for this argument to be before the closure, to improve readability.
@huonw Comments addressed. |
…s, r=Veykril Consider field attributes when converting from tuple to named struct and the opposite Fixes rust-lang#17983. I tried to use the `SourceChangeBuilder::make_mut()` API, but it duplicated the attribute...
No description provided.